<template>
  <div>
      <div class="incolumn_countr">
      <div>
        <div>
          <hy-search
            ref="query"
            :searchTitle="searchTitle"
            v-model="searcher"
            :col="6"
            @search="getlist(0)"
          ></hy-search>
        </div>
        <!-- <el-button class="add_task" type="primary" size="small" @click="addTask"> 发公告</el-button> -->
      </div>
    </div>
    <div class="table-box">
      <template>
        <el-table
          :data="tableData"
          style="width: 100%;background-color:#fff"
          :cell-style="rowClass"
              :max-height="620"
          :header-cell-style="headClass"
          stripe
        >
         <el-table-column prop="xuhao" label="序号" align="center"></el-table-column>
          <el-table-column prop="syear" label="年份" align="center"></el-table-column>
          <el-table-column prop="smonth" label="月份" align="center"></el-table-column>
          <el-table-column prop="plannums" label="销售计划" align="center"></el-table-column>
          <el-table-column prop="x.factnums" label="实际数量" align="center"></el-table-column>
          <el-table-column prop="x.createon" label="创建时间" align="center"></el-table-column>
          <el-table-column prop="x.preparename" label="制单人" align="center"></el-table-column>
          <el-table-column prop="states" label="状态" align="center"></el-table-column>
          <el-table-column label="操作" align="center"  width="200">
            <template slot-scope="scope">
              <el-button size="small" type="warning"  v-show="scope.row.states!=='已查看'" @click="jiance(scope.row.x.planno,0)">查看</el-button>
              <el-button size="small" type="primary" @click="xiangq(scope.row.x.planno,1)">详情</el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>
            <template>
              <el-pagination
                      background
        layout="prev, pager, next"
        :current-page="current"
        :page-size="pagesize"
        @current-change="handleCurrentChange"
        :total="total"
            style="text-align：center"
          ></el-pagination>
        </template>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
       total: 1,
      current:1,
      pagesize:10,
       imageUrl: '',
      dialogVisible: false,
      searchTitle: [
        {
          type: "input",
          name: "customProductName",
          label: "输入搜索",
          placeholder: "请输入制单人",
          prop: "customProductName"
        },
        {
          type: "date2",
          name: "issuanceDate",
          label: "输入时间",
          placeholder: "请选择输入时间",
          prop: "issuanceDate"
        }
      ],
      searcher: {
        customProductName: "",
        customProductNo: "",
        issuanceDate: ""
      },
      tableData: [],
        value: '',
    };
  },
    created() {
      this.empno =JSON.parse(localStorage.getItem('empno'))
    this.getlist(0)
    // this.getlists()
  },
  methods: {
             // 分页
    handleCurrentChange(e) {
      this.getlist(e - 1);
    },
    // 表头样式设置
    headClass() {
      return "text-align:center;";
    },
    // 表格样式设置
    rowClass() {
      return "text-align: center;";
    },
    jiance(planno,e) {
           this.$router.push({
        path: "/PzSalesaddPlan",
        query: { planno: planno,e:e}
      });
    },
        //订单计划详情
    xiangq(planno,e) {
      this.$router.push({
        path: "/PzSalesaddPlan",
        query: { planno: planno,e:e}
      });
    },
         //列表数据
    getlist(page) {
      let arr = {
        pn: page,
        PerPageSize: 10,
        key: this.searcher.customProductName
          ? this.searcher.customProductName
          : "",
        start: this.searcher.issuanceDate[0]
          ? this.searcher.issuanceDate[0]
          : "",
        end: this.searcher.issuanceDate[1] ? this.searcher.issuanceDate[1] : ""
      };
      let arr1 = JSON.stringify(arr);
      axios(
        "apis/PurchasingManagement.asmx/List_Purchasing?index=5&jsondata=" + arr1+"&empno="+this.empno
      ).then(({ data }) => {
 var datas = this.$x2js.xml2js(data);
         var stafflist = JSON.parse(datas.string.__text);
            this.tableData=stafflist
                  console.log(stafflist)
               for (var i = 0; i < stafflist.length; i++) {
          this.tableData[i].xuhao = 1 + i + 10 * page;
        }
              for (var i = 0; i < stafflist.length; i++) {
            var dd = new Date(parseInt(stafflist[i].x.createon.substr(6, 13)));
                   var y = dd.getFullYear();
          var m = dd.getMonth() + 1;
          m = m < 10 ? "0" + m : m;
         var d = dd.getDate();
          d = d < 10 ? "0" + d : d;
         stafflist[i].x.createon =  y + "-" + m + "-" + d + " " ;
          }
      });
    },
              getlists() {
      let arr = { start: "", end: "", key: "", pn: 0, PerPageSize: 10000 };
      let arr1 = JSON.stringify(arr);
      axios(
     "apis/PurchasingManagement.asmx/List_Purchasing?index=5&jsondata=" + arr1+"&empno="+this.empno
      ).then(({ data }) => {
        let data1 = this.$x2js.xml2js(data);
        let data2 = JSON.parse(data1.string.__text);
       this.total=data2.length
      });
    },
   
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/base.scss";
@import "@/assets/scss/search.scss";
.incolumn_countr {
  width: 97%
}
.container {
    overflow-x: hidden;
  background-color: $bgcolor;
}
.top-box {
  width: 100%;
  height: 100px;
  padding-left: 1%;
  padding-top: 10px;
  //   border: 1px solid $red;
  background-color: $white;
    overflow-x: hidden;
  margin-bottom: 20px;
}
.table-box {
  width: 98%;
  height: 620px;
  //   border: 1px solid $red;
  overflow-x: hidden;
  margin: 0 auto;
}
.el-pagination {
  margin-top: 20px;
  text-align: center;
}
.btn-box {
  width: 30%;
  height: 60px;
  overflow: hidden;
  // border: 1px solid $red;
  float: right;
  margin-right: 2%;
}
.sea-box {
  width: 90%;
  float: left;
  // border: 1px solid red;
}
.hy_search {
  margin-top: 10px;
}
.sear-box {
  width: 8%;
  float: left;
  margin-left: 2%;
  //  border: 1px solid red;
}
.btn {
  float: right;
  margin-top: 10px;
}
.diatop-box {
  width: 100%;
  height: 50px;
  border-top: 1px solid $bordercolor;
}
.diatop-box ul {
  overflow: hidden;
}
.diatop-box ul li {
  width: 33%;
  height: 50px;
  float: left;
  line-height: 50px;
  // border: 1px solid red;
}
.diatop-box ul li span {
  margin-left: 5%;
}
.word-box {
  width: 100%;
  height: 30px;
  font-weight: bold;
  text-align: left;
  line-height: 30px;
}
.eit {
  height: 30px;
}
.cont-box {
  width: 100%;
  // height: 300px;
  margin: 0 auto;
  overflow: hidden;
  // border: 1px solid red;
}
.cont-box ul {
  overflow: hidden;
}
.item-box {
  width: 14%;
  height: 50px;
  float: left;
  line-height: 50px;
  text-align: center;
  font-size: 12px;
  border-top: 1px solid $bordercolor;
}
.item1-box {
  width: 28.5%;
  height: 50px;
  float: left;
  line-height: 50px;
  text-align: center;
  font-size: 12px;
  border-top: 1px solid $bordercolor;
}
.diabottom-box {
  width: 100%;
  overflow: hidden;
  border-top: 1px solid $bordercolor;
}
.dialeft-box {
  width: 74%;
  height: 80px;
  float: left;
  // border: 1px solid red;
}
.diabtn-box {
  width: 100%;
  height: 80px;
  float: left;
  line-height: 80px;
  text-align: center;
}
.digword-box{
  width: 20%;
  height: 80px;
  float: left;
    line-height: 80px;
  text-align: center;
  //  border: 1px solid red;
}
.diaitem1-box{
  width: 100px;
  height: 80px;
    float: left;
        line-height: 80px;
  text-align: center;
  // border: 1px solid red;
    line-height: 80px;
}
.digpeo-box{
  float: right;
     line-height: 80px;
}
 .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 50px;
    height: 50px;
    line-height: 50px;
    text-align: center;
  }
  .avatar {
    width: 50px;
    height: 50px;
    display: block;
  }
  .herd_bud {
  margin-top: -40px;
  height: 20px;
  width: 5px;
  background-color:$Header_color;
}
.from_bt {
  margin-top: -20px;
  margin-left: 10px;
  font-size: $font-size-medium-x;
  font-weight: bold;
}
.throth-box{
  width: 100%;
  height: 60px;
  // border: 1px solid red;
  line-height: 60px;
   border-top: 1px solid $bordercolor;
  // text-align: center;
}
.throth-box .el-form{
  margin-top: 10px;
    margin-left: 20px;
}
.add-box {
    width: 100%;
  height: 60px;
   border-top: 1px solid $bordercolor;
  line-height: 60px;
}
.add-box ul {
  overflow: hidden;
}
.add-box ul li {
  width: 33%;
  height: 60px;
  float: left;
  line-height: 60px;
  // border: 1px solid red;
}
.add-box ul li span {
  margin-left: 5%;
}
</style>
